package com.example.controller;

import com.example.domain.User;
import com.example.service.LoginService;
import com.example.utils.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class LoginController {
    @Resource
    private LoginService loginService;

    @PostMapping("/user/login")
    public R login(@RequestBody User user) {
        return R.ok(loginService.login(user));
    }

    @RequestMapping("/user/logout")
    public R logout() {
        loginService.logout();
        return R.ok("退出成功");
    }

}
